<?php
//
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'detail';
$return=array();
if($_RQ['op']=='main'){
	$return['setting']=$this->plugin_setting('basic');
	$return['list']=array();
	exi($return);
}
// js 获取数据
if($_RQ['op']=='getlist'){
	$post=get_postdata();
	$params=array('uniacid'=>$_SESSION['uniacid']);
	$pindex = max(1, intval($post['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_weishop_goods',$params,array($pindex,$psize),$total,$fields,'','display desc');
	$return['list']=$list;
	exi($return);
}
if($_RQ['op']=='detail'){
	$id=intval($_RQ['id']);
	$item=pdo_get('jy_weishop_store',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
	$item['logo'] = tomedia($item['logo']);
	//exi($item['onlinetime'],'error');
	$item['onlinetime'] = json_decode($item['onlinetime'],true);
	$item['photo_list'] = json_decode($item['photo_list'],true);
	$item['hdps'] = json_decode($item['hdps'],true);
	//print_r($item['onlinetime']);exit;
	if (!(empty($item['tag']))) {
		$tags = explode(',', $item['tag']);
		if (!(empty($tags))) {
			foreach ($tags as &$tag ) {
				if (2 < mb_strlen($tag, 'UTF-8')) {
						$lable = mb_substr($tag, 0, 2, 'UTF-8');
				}
			}
			unset($tag);
		}
		$item['taglist'] = $tags;
		$item['hastag'] = 1;
	}
	else{
		$item['hastag'] = 0;
	}
	if (!(empty($item['label']))) {
		$lables = explode(',', $item['label']);
		if (!(empty($lables))) {
			foreach ($lables as &$lable ){
				if (4 < mb_strlen($lable, 'UTF-8')) 
				{
					$lable = mb_substr($lable, 0, 4, 'UTF-8');
				}
			}
			unset($lable);
		}
		$item['labellist'] = $lables;
		$item['haslabel'] = 1;
	}
	else {
		$item['haslabel'] = 0;
	}
	$return['item']=$item;
	exi($return);
}	
?>